import java.io.*;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.microedition.lcdui.Font;

public final class bu {

    private o a;
    private Hashtable b;
    private Hashtable c;

	public bu() {
		b = new Hashtable();
		c = new Hashtable();
	}

	public final o a(String s) {
		o o1 = (o) b.get(s);
		if (o1 == null) {
			o1 = new o(s);
			b.put(s, o1);
		}
		return o1;
	}

	public final o a(String s, String s1) {
		o o1 = (o) b.get(s);
		if (o1 != null)
			return o1;
		o o2 = (o) b.get(s1);
		if (o2 != null)
			return o2;
		else
			return a(s);
	}

    public final o a() {
		if (a == null)
			a = a("default");
		return a;
	}

	public final synchronized u b(String s) {
		u u1 = (u) c.get(s);
		if (u1 == null)
			if (s.startsWith("/")) {
				u1 = u.a(s);
				c.put(s, u1);
			} else {
				u1 = u.a();
			}
		return u1;
	}

    public final synchronized void a(String s, u u1) {
		c.put(s, u1);
	}

	public final synchronized void b() {
		b.clear();
		c.clear();
	}

	public final void c(String s) {
		for (Enumeration enumeration = b.elements(); enumeration
				.hasMoreElements(); ((o) enumeration.nextElement()).a())
			;
		c.clear();
		InputStream inputstream = ce.d(s);
		if (inputstream == null)
			return;
		try {
			a(inputstream);
		} catch (IOException ioexception) {
			ce.a("Could not read theme", ioexception);
		}
		for (Enumeration enumeration1 = b.elements(); enumeration1
				.hasMoreElements(); enumeration1.nextElement())
			;
		return;
	}

    public final void a(InputStream inputstream) throws IOException {
        DataInputStream datainputstream = new DataInputStream(inputstream);
        int i = datainputstream.readUnsignedByte();
        int j = datainputstream.readUnsignedShort();
        for(int k = 0; k < j; k++)
            a(a(datainputstream.readUTF()), datainputstream, i);

        datainputstream.close();
        if(ce.f == 1)
            c();
    }

    private static void a(DataInputStream datainputstream, g g1, int i)
			throws IOException {
		byte byte0 = 0;
		if (i > 1)
			byte0 = datainputstream.readByte();
		g1.d = datainputstream.readUnsignedByte();
		g1.c = datainputstream.readUnsignedByte();
		g1.e = datainputstream.readUnsignedByte();
		g1.b = datainputstream.readUnsignedByte();
		if (i > 1) {
			int j = bh.q();
			if ((byte0 & 1) != 0)
				g1.d = (j * g1.d) / 100;
			if ((byte0 & 2) != 0)
				g1.c = (j * g1.c) / 100;
			if ((byte0 & 4) != 0)
				g1.e = (j * g1.e) / 100;
			if ((byte0 & 8) != 0)
				g1.b = (j * g1.b) / 100;
		}
	}

    private static Font a(DataInputStream datainputstream) throws IOException {
		int i = datainputstream.readUnsignedByte();
		if ((i & 8) == 0 && ce.a(22))
			i = i & 0xffffffef | 8;
		return Font.getFont(i & 0x60, i & 7, i & 0x18);
	}

	private static int b(DataInputStream datainputstream) throws IOException {
		return datainputstream.read() << 16 | datainputstream.read() << 8
				| datainputstream.read();
	}

	private u c(DataInputStream datainputstream) throws IOException {
		return b(datainputstream.readUTF());
	}

	private static int a(DataInputStream datainputstream, int i)
			throws IOException {
		if (i == 1)
			return datainputstream.readShort();
		byte byte0 = datainputstream.readByte();
		short word0;
		if (((byte0) & 0x80) == 0)
			word0 = (short) (datainputstream.readByte());
		else
			word0 = datainputstream.readShort();
		switch (byte0 & 0xffffff7f) {
		case 1: // '\001'
			return (word0 * bh.q()) / 100;

		case 2: // '\002'
			return -word0;

		case 0: // '\0'
		default:
			return word0;
		}
	}

    private int b(DataInputStream datainputstream, int i) throws IOException {
		if (i == 1)
			return datainputstream.readInt();
		if (datainputstream.readByte() == 0)
			return datainputstream.readInt();
		else
			return a(datainputstream, i);
	}

	private void a(o o1, DataInputStream datainputstream, int i)
			throws IOException {
        int j = datainputstream.readUnsignedByte();
        if((j & 1) != 0)
            o1.c = a(datainputstream, i);
        if((j & 2) != 0)
            o1.d = a(datainputstream, i);
        if((j & 4) != 0)
            o1.e = datainputstream.readByte();
		if ((j & 8) != 0) {
			o1.f = new g();
			a(datainputstream, o1.f, i);
		}
		if (i == 1 || (j & 0x40) != 0) {
			ch ch1 = null;
			switch (datainputstream.readUnsignedByte()) {
			case 0: // '\0'
                ch1 = ch.f;
                break;

            case 1: // '\001'
            case 3: // '\003'
                (ch1 = new ch(1)).h = new g(b(datainputstream));
                a(datainputstream, ((g) (ch1)), i);
                break;

            case 2: // '\002'
                ch1 = new ch(1);
                int l = b(datainputstream);
                int k1 = b(datainputstream);
                int l1 = b(datainputstream);
                int i2 = b(datainputstream);
                ch1.h = new g(i2, k1, l, l1);
                a(datainputstream, ((g) (ch1)), i);
                break;

            case 4: // '\004'
                (ch1 = new ch(2)).i = c(datainputstream);
                a(datainputstream, ((g) (ch1)), i);
                break;

            case 5: // '\005'
                ch1 = new ch(0);
                a(datainputstream, ((g) (ch1)), i);
                break;

            default:
                throw new IOException("unexpected border type");
            }
            o1.g = ch1;
        }
        if (i == 1 || (j & 0x80) != 0) {
			at at1;
			int i1 = datainputstream.readUnsignedByte();
			switch (i1) {
            case 0: // '\0'
                at1 = at.a;
                break;

            case 1: // '\001'
            	at1 = new at(1);
                at1.e = b(datainputstream);
                break;

            case 2: // '\002'
            	at1 = new at(2);
                at1.e = b(datainputstream);
                at1.f = b(datainputstream);
                break;

            case 3: // '\003'
            	at1 = new at(3);
                at1.e = b(datainputstream);
                at1.f = b(datainputstream);
                break;

            case 4: // '\004'
            	at1 = new at(4);
                at1.d = c(datainputstream);
                at1.e = b(datainputstream);
                at1.g = datainputstream.readShort();
                break;

            case 5: // '\005'
            case 6: // '\006'
            	at1 = new at(i1);
                at1.d = c(datainputstream);
				if (i1 == 5 && i > 1) {
					at1.f = datainputstream.readByte();
					if (at1.f == 2)
						at1.e = b(datainputstream);
				}
				at1.c = new g();
				a(datainputstream, at1.c, i);
				break;

			default:
				throw new IOException("unexpected background type");
			}
			o1.h = at1;
		}
		if ((j & 0x10) != 0) {
			o1.i = new g();
			a(datainputstream, o1.i, i);
		}
        int k = datainputstream.readUnsignedShort();
        if((k & 1) != 0)
            o1.j = a(datainputstream);
        if((k & 2) != 0)
            o1.k = a(datainputstream);
        if((k & 4) != 0)
            o1.l = a(datainputstream);
        if((k & 8) != 0)
            o1.m = a(datainputstream);
        if((k & 0x10) != 0)
            o1.n = b(datainputstream);
        if((k & 0x20) != 0)
            o1.o = b(datainputstream);
        if((k & 0x40) != 0)
            o1.p = b(datainputstream);
        if((k & 0x80) != 0)
            o1.q = b(datainputstream);
        if((k & 0x100) != 0)
            o1.r = c(datainputstream);
        if((k & 0x200) != 0)
            o1.s = c(datainputstream);
        if((k & 0x400) != 0)
            o1.t = c(datainputstream);
        if((k & 0x800) != 0)
            o1.u = c(datainputstream);
        if((k & 0x1000) != 0)
            o1.v = b(datainputstream, i);
        if((k & 0x2000) != 0)
            o1.w = b(datainputstream, i);
        if((k & 0x4000) != 0)
            o1.x = b(datainputstream, i);
		int j1 = 16384 << 1;
		if ((k & j1) != 0)
			o1.y = b(datainputstream, i);
		if ((j & 0x20) != 0) {
			o1.z = new o(o1.b, o1);
			a(o1.z, datainputstream, i);
		} else {
			o1.z = null;
		}
		o1.A = null;
    }

    public final void c() {
		for (Enumeration elem = b.elements(); elem.hasMoreElements(); ((o) elem
				.nextElement()).i())
			;
	}
}